#include "MiniMotor_PID.h"

PID_Value PID_value ={
	.SetPoint =75,
	.PrevError =0,
	.LastError =0,
	.SumError =0,
	.Proportion =P_DATA,
	.Integral =I_DATA,
	.Derivative =D_DATA,
};

int IncPIDCalc(int NextPoint) 
{
  int iError =0,iIncpid =0;         
	
  iError=PID_value.SetPoint-NextPoint;                    
  iIncpid=(PID_value.Proportion * iError)                 
              -(PID_value.Integral * PID_value.LastError)     
              +(PID_value.Derivative * PID_value.PrevError);  
              
  PID_value.PrevError=PID_value.LastError;                    
  PID_value.LastError=iError;
  return(iIncpid);                                    
}


